import logging

### MENU_TYPE
SERVER="SERVER"
SETTING="SETTING"

class ServerModel(object):
	"""docstring for ClassName"""
	inIp="";
	outIp="";
	password="";
	remark="";
	user="";
	loginCmd=[]
	item=""
	remark=""
	menu_type=""

	def __from_server_config(self,config):
		self.inIp = config["inIp"]
		self.outIp = config["outIp"]
		self.password=config["password"]
		self.remark = config["remark"]
		self.user = config["user"]
		self.loginCmd = config["loginCmd"]
	
	def from_config(self,config,type):
		if(type == SERVER):
			self.__from_server_config(config=config)
			self.menu_type = type
			return self
		elif(type == SETTING):
			self.__from_setting_config(config)
			self.menu_type = type
			return self
		else:
			logging.error("未知的菜单类型%s",type)

	def __from_setting_config(self,config):
		self.item = config["item"]
		self.remark  = config["remark"]